// pages/collect/collect.js
const http = require('../../ajax.js')
const api = require('../../api.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scxq:[],
    col:true,
    toshop:[],
    searchValue: [],
    conShow: true,
    topText:false,
    gou:true,
    shop: true,
    all:true,
    zongimg:false,
  },
  aa(e){
    let data = {
      "memberId": 589,
      "shopId": 18,
      "storeId": 56200,
      "goodsName": "", 
      "currentPage": 1,
      "pageSize": 10
    }
    http(api.scxq,"data", data,"POST").then(res => {
      console.log( res)
      if (res.data.status.statusCode === 0){
        this.setData({
        scxq:this.data.scxq
        })
      }
      console.log(this.data.scxq)
    })
  },

  bb(i) {
    let data = {
      memberId: 589,
      customerId:589 ,
      shopId:18 ,
      storeId: 56200
    }
    http(api.toshop, "data", data, "POST").then(res => {
      //console.log(res)
      if (res.data.status.statusCode === 0) {
        this.setData({
          toshop: this.data.toshop
        })
      }
      //console.log(this.data.toshop)
    })
  },


  textclick() {
    this.setData({
      zongimg:true,
      topText: !this.data.topText,
      gou: !this.data.gou,
    })
  },
  textclicktwo(){
    this.setData({
      topText: !this.data.topText,
      gou: !this.data.gou,
      zongimg: false,
    })
  },
  shopxuan() {
    this.setData({
      //all:true,
      shop:!this.data.shop,
    })
  },
  shopquan() {
    this.setData({
      //all:true,
      all: !this.data.all,
      shop: !this.data.shop
    })
  },
 
   
  
  quxiao: function (e) {
    console.log(e)
    let num = e.currentTarget.dataset.num;
    wx.showModal({
      title: '删除确认',
      content: '您确认取消这些收藏吗？',
      confirmColor: "#F84435",

      success: (res) => {
        if (res.confirm) {
          http(api.scxq, 'params', {
            orderNo: num
          }, 'post')
            .then(res => {
              if (res.data.status.statusCode === 0 && res.data.result) {
                wx.showToast({
                  title: '删除成功',
                  icon: 'none'
                })
                setTimeout(() => {
                  this.onShow();
                }, 1500)
              } else {
                wx.showToast({
                  title: '删除失败',
                  icon: 'none'
                })
              }
            })
        }
        if (res.cancel) {
          console.log('取消删除')
        }

      }
    })
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },
  gouwu() {
    wx.switchTab({
      url: '/pages/cart/cart'
    })
  },
  xiang() {
    wx.navigateTo({
      url: '/pages/home/xiang/xiang'
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.aa();
   this.bb();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})